import '../helper/dioHelper2.dart';

class SignItem {
  int ID;
  String SpaceID;
  int State;
  String Title;
  String UserId;
  bool IfOK;
  String QM;
  String QmTime;

  SignItem(this.ID, this.SpaceID, this.State, this.Title, this.UserId,
      this.IfOK, this.QM, this.QmTime);
  SignItem.fromJson(Map<String, dynamic> json)
      : ID = json["ID"],
        SpaceID = json["SpaceID"],
        State = json["State"],
        Title = json["Title"],
        UserId = json["UserId"],
        IfOK = json["IfOK"],
        QM = json["QM"],
        QmTime = json["QmTime"];
  Map<String, dynamic> toJson() => {
        'ID': ID,
        'SpaceID': SpaceID,
        'State': State,
        'Title': Title,
        'UserId': UserId,
        'IfOK': IfOK,
        'QM': QM,
        'QmTime': QmTime,
      };
  static Future<bool> Add(SignItem x1) async {
    var response = await DioHelper.Post("/SignItem/Add", x1.toJson());
    if (response.statusCode == 200) return true;
    return false;
  }

  static Future<bool> Update(SignItem x1) async {
    var response = await DioHelper.Post("/SignItem/Update", x1.toJson());
    if (response.statusCode == 200) return true;
    return false;
  }

  static Future<bool> Delete(SignItem x1) async {
    var st = x1.toJson();
    var response = await DioHelper.Post("/SignItem/Delete", x1.toJson());
    if (response.statusCode == 200) return true;
    return false;
  }

  static Future<SignItem?> Get(String where, dynamic data) async {
    var response = await DioHelper.Post("/SignItem/GetByWhere", {
      "Where": where,
      "obj": data,
    });

    if (response.statusCode == 200) return new SignItem.fromJson(response.data);
    return null;
  }

  static Future<List<SignItem>> GetList(String sID) async {
    var response = await DioHelper.Get("/SignItem/GetList?sID=" + sID, {});

    var list1 = <SignItem>[];
    if (response.statusCode == 200) {
      //print(response.data);
      for (var x in response.data) {
        list1.add(new SignItem.fromJson(x));
      }
    }
    return list1;
  }

  static Future<List<SignItem>> GetAllList() async {
    var response = await DioHelper.Get("/SignItem/GetAllList", {});
    var list1 = <SignItem>[];
    if (response.statusCode == 200) {
      for (var x in response.data) {
        list1.add(new SignItem.fromJson(x));
      }
    }
    return list1;
  }
}
